package com.cskaoyan.controller;

import com.cskaoyan.bean.MarketAd;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AdminAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chengyi
 * @date 2022/10/12 10:31
 */
@RestController //响应JSON数据
@RequestMapping("admin/ad")
public class AdminAdController {
    @Autowired
    AdminAdService adminAdService;


    /**
     * 广告页面查询
     * @param info
     * @return
     */
    //page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info,String name,String content){
        CommonData<MarketAd> data = adminAdService.list(info,name,content);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 添加广告
     * @param
     * @return
     */
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MarketAd marketAd){
        MarketAd data = adminAdService.create(marketAd);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 编辑广告
     * @param
     * @return
     */
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketAd marketAd){
        MarketAd data = adminAdService.update(marketAd);
        return BaseRespVo.ok(data,"成功");
    }

    /**
     * 删除广告
     * @param marketAd
     * @return
     */
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketAd marketAd){
        adminAdService.delete(marketAd);
        return BaseRespVo.ok("成功");
    }



}
